<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .denmo {
            background-color: red;
            width: 200px;
            height: 200px;
        }
        
        .box1 {
            background-color: cyan;
            width: 300px;
            height: 200px;
        }
        
        .box2 {
            background-color: yellow;
            width: 200px;
            height: 100px;
        }
        
        ul {
            background-color: aqua;
            width: 100px;
            height: 300px;
            overflow: auto;
        }
        
        li {
            background-color: antiquewhite;
            width: 100px;
            height: 100px;
        }
    </style>
</head>

<body>
    <div class="apo">
        <a href="https://baidu.com" @click="showInfo1">点我</a>
        <a href="https://baidu.com" @click.prevent="showInfo1">阻止默认事件</a>

        <div class="denmo" @click="showInfo1">
            <!-- 阻止冒泡 -->
            <a href="#" @click.stop="showInfo1">点我</a>
        </div>

        <!-- 只触发一次 -->
        <a href="#" @click.once="showInfo1">点我</a>

        <!-- capture捕获 停止冒泡 -->
        <div class="box1" @click.capture="showMsg(1)">
            <div class="box2" @click="showMsg(2)"></div>
        </div>
        <br>

        <!-- self 当event是自己才触发事件 -->
        <div class="box1" @click.self="showMsg(1)">
            <div class="box2" @click.self="showMsg(2)"></div>
        </div>
        <br>

        <!-- wheel鼠标滚轮 scroll滚动条 -->
        <ul @wheel="msg" @scroll="msg">
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
        </ul>
        <br>

        <!-- passive优先相应默认事件 -->
        <ul @wheel.passive="msg1" @scroll="msg1">
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
            <li>1234</li>
        </ul>

    </div>
    <script>
        const vm = new Vue({
            data() {
                return {

                }
            },
            methods: {
                showInfo1() {
                    alert("你好")
                },
                showMsg(a) {
                    console.log(a);
                },
                msg() {
                    console.log("2");
                },
                msg1() {
                    for (let index = 0; index < 50000; index++) {
                        console.log(2);
                    }
                }
            }
        })
        vm.$mount('.apo')
    </script>
</body>

</html>